<%@ page language="java" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <base href="${base}/"/>
    <meta charset="utf-8"/>
    <title>${goods.name}_蜗牛嗨购商城</title>
    <link rel="stylesheet" type="text/css" href="/css/index.css" />
    <script type="text/javascript" src="js/jquery-3.7.1.min.js"></script>
    <script type="text/javascript">
        //用于用户中心左边菜单栏的选择项的样式
        function setSelectedClass(url){
            $('div.cont ul.list li a[href~="'+url+'"]').parent().addClass("current");
        }
    </script>
    <script type="text/javascript">
        $(function () {
            $("#add").on("click", function () {
                $("#buyNums").val(parseInt($("#buyNums").val()) + 1);
            });
            $("#reduce").on("click", function () {
                if ($("#buyNums").val() == 1) {
                    return;
                }
                $("#buyNums").val(parseInt($("#buyNums").val()) - 1);
            });

        });
        $(function(){
            $('.mycart').hover(
                function(){
                    $('#div_mycart').show('slow');
                },
                function(){
                    $('#div_mycart').hide('slow');
                }
            );
        });
        $(function() {
            $('.allsort').hover(function() {
                $('#div_allsort').show();
            }, function() {
                $('#div_allsort').hide();
            });
        });



        function order_add() {
            location.href = "order/add?id=1&num="+$("#buyNums").val();
        }
        function  joinCart(goodid){

            let num = $("#buyNums").val();
            //发送请求
            $.ajax({
                url:"/car/add",
                type:"post",
                data:{goodid,num},
                success:(res)=>{
                    if(res=="success"){
                        alert("添加成功，跳转到购物车页面");
                        location.href="/car";
                    }else if(res=="fail:user"){
                        alert("请先登录");
                        location.href="/user/login"
                    }else{
                        alert("添加购物车失败");
                    }
                }
            })
        }

    </script>

</head>
<body class="index">
<div id="content"></div>
<div class="container">
    <div class="header">
        <h1 class="logo">
            <a title="" style="background:url(images/logo.png);" href="/">电子商务平台</a>
        </h1>
        <ul class="shortcut">
            <li class="first"><a href="ucenter">我的账户</a></li>
            <li><a href="ucenter/order">我的订单</a></li>
            <li class='last'><a href="">使用帮助</a></li>
        </ul>
        <p class="loginfo">
            <c:if test="${not empty sessionScope.loginUser}">
                ${loginUser.account}您好，欢迎您来到${site}购物！[<a href="/logout" class="reg">安全退出</a>]
            </c:if>
            <c:if test="${empty sessionScope.loginUser}">
                [<a href="/login">登录</a>
                <a class="reg" href="/register">免费注册</a>]
            </c:if>
        </p>
    </div>
    <div class="navbar">
        <ul>
            <li><a href="">首页</a></li>
        </ul>
        <div class="mycart">
            <dl>
                <dt>
                    <a href="/cart">购物车<b name="mycart_count">0</b>件
                    </a>
                </dt>
                <dd>
                    <a href="/cart">去结算</a>
                </dd>
            </dl>



        </div>
    </div>
    <div class="searchbar">
        <div class="allsort">
            <a href="javascript:void(0);">全部商品分类</a>

            <!--总的商品分类-开始-->
            <ul class="sortlist" id='div_allsort' style='display:none'>


                    <li>
                        <h2>
                            <a href ="">数码家电</a>
                        </h2>
                    </li>

            </ul>
        </div>

        <div class="searchbox">
            <form method='get' action=''>
                <input type='hidden' name='controller' value='site' /> <input
                    type='hidden' name='action' value='search_list' /> <input
                    class="text" type="text" name='word' autocomplete="off"
                    value="输入关键字..." /> <input class="btn" type="submit" value="商品搜索"
                                                    onclick="checkInput('word','输入关键字...');" />
            </form>

        </div>
        <div class="hotwords">热门搜索：</div>
    </div>
    <div class="wrapper clearfix">
        <div class="summary">
            <h2>${goods.name}</h2>
            <!--基本信息区域-->
            <ul>
                <li><span class="f_r light_gray">商品编号：<label
                        id="data_goodsNo">${goods.no}</label></span></li>
                <li id="priceLi">销售价：<b class="red2"><span
                        id="real_price">￥${goods.salePrice}</span></b></li>
                <li>市场价：<s id="data_marketPrice">￥${goods.marketPrice}</s>
                </li>
                <li>库存：现货<span>(<label id="data_storeNums">${goods.stock}</label>)
					</span></li>
            </ul>
            <div class="current">
                <dl class="m_10 clearfix">
                    <dt>购买数量：</dt>
                    <dd>
                        <input class="gray_t f_l" type="text" id="buyNums" value="1"
                               maxlength="5"/>
                        <div class="resize">
                            <a class="add" id="add"></a> <a class="reduce" id="reduce"></a>
                        </div>
                    </dd>
                </dl>
                <input class="submit_buy" type="button" id="buyNowButton"
                       value="立即购买" onclick="order_add()"/>
                <div class="shop_cart" style="z-index:1">
                    <input class="submit_join" type="button" id="joinCarButton"
                           onclick="joinCart(${goods.id});" value="加入购物车"/>

                    <div class="shopping" id="product_myCart" style='display:none'>
                        <dl class="cart_stats">
                            <dt class="gray f14 bold">
                                <a class="close_2 f_r" href="javascript:closeCartDiv();"
                                   title="关闭">关闭</a> <img src="images/front/right_s.gif"
                                                              width="24" height="24" alt=""/>成功加入购物车
                            </dt>
                            <dd class="gray">
                                目前选购商品共<b class="orange" name='mycart_count'></b>件<span>合计：<b
                                    name='mycart_sum'></b></span>
                            </dd>
                            <dd>
                                <a class="btn_blue bold" href="">进入购物车</a><a
                                    class="btn_blue bold" href="javascript:void(0)"
                                    onclick="closeCartDiv();">继续购物>></a>
                            </dd>
                        </dl>
                    </div>
                </div>
            </div>

        </div>

        <!--图片放大镜-->
        <div>
            <div class="pic_show"
                 style="width:435px;height:435px;position:relative;z-index:5;padding-bottom:5px;">
                <img src="${goods.image}" title="${goods.name}"
                     style="border:none;width:435px;height:435px"/>
            </div>
        </div>
    </div>

    <div class="wrapper clearfix container_2">
        <!--左边栏-->
        <div class="sidebar f_l">
            <div class="box m_10">
                <div class="title">热卖商品</div>
                <div class="content">
                    <ul class="ranklist">

                    </ul>
                </div>
            </div>
        </div>

        <!--滑动面tab标签-->
        <div class="main f_r" style="overflow:hidden">
            <div class="uc_title" name="showButton">
                <label class="current"><span>商品详情</span></label>
            </div>
            <div name="showBox">
                <!-- 商品详情 start -->
                <div>${goods.description}</div>
                <!-- 商品详情 end -->
            </div>
        </div>
    </div>
    <div class="footer">
        <p class="links">
            <a href="">关于我们</a>|<a href="">常见问题</a>|<a href="">安全交易</a>|<a href="">购买流程</a>|<a
                href="">如何付款</a>|<a href="">联系我们</a>|<a href="">合作提案</a>
        </p>
        Copyright 蜗牛学苑© 2015-2024 <a class="copyys" target="_blank" href="">蜀ICP备01000010号</a>
    </div>
</div>
</body>
</html>